package com.example.baserecyclerviewadapterdemo.anim;

import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.view.View;
import android.view.animation.Interpolator;

import com.chad.library.adapter.base.animation.BaseAnimation;

import org.jetbrains.annotations.NotNull;

public class CustomAnimation2 implements BaseAnimation {
    @NotNull
    @Override
    public Animator[] animators(@NotNull View view) {
        Animator translationX = ObjectAnimator.ofFloat(view,"translationX",-view.getRootView().getWidth(),0f);
        translationX.setDuration(800);
        translationX.setInterpolator(new Interpolator() {
            @Override
            public float getInterpolation(float input) {
                float factor = 0.7f;
                return (float) (Math.pow(2.0,-10.0 * input) * Math.sin(input - factor / 4) * (2 * Math.PI) / factor + 1);
            }
        });
        return new Animator[]{translationX};
    }
}
